# Copyright 2024 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Remove unused tables

Revision ID: a6f358254cbd
Revises: 692f2f936258
Create Date: 2025-06-26 19:13:30.247095

"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "a6f358254cbd"
down_revision = "692f2f936258"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("project_users")
    op.drop_index("_users_uc", table_name="users")
    op.drop_table("users")
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "users",
        sa.Column("id", mysql.INTEGER(), autoincrement=True, nullable=False),
        sa.Column(
            "name",
            mysql.VARCHAR(charset="utf8mb3", collation="utf8mb3_bin", length=255),
            nullable=True,
        ),
        sa.PrimaryKeyConstraint("id"),
        mysql_collate="utf8mb3_bin",
        mysql_default_charset="utf8mb3",
        mysql_engine="InnoDB",
    )
    op.create_index("_users_uc", "users", ["name"], unique=True)
    op.create_table(
        "project_users",
        sa.Column("project_id", mysql.INTEGER(), autoincrement=False, nullable=True),
        sa.Column("user_id", mysql.INTEGER(), autoincrement=False, nullable=True),
        sa.ForeignKeyConstraint(
            ["project_id"], ["projects.id"], name="_project_users_project_id_fk"
        ),
        sa.ForeignKeyConstraint(
            ["user_id"], ["users.id"], name="_project_users_user_id_fk"
        ),
        mysql_collate="utf8mb3_bin",
        mysql_default_charset="utf8mb3",
        mysql_engine="InnoDB",
    )
    # ### end Alembic commands ###
